package com.yoyo.yyadsdk.common;

import android.content.Context;
import android.content.Intent;
import com.yoyo.ad.main.YoYoAdManager;
import com.yoyo.yyadsdk.main.KernelService;
import com.yoyo.yyadsdk.util.ApiManage;
import com.yoyo.yyadsdk.util.GreenDaoManager;
import com.yoyo.yyadsdk.util.SpUtil;


import static com.yoyo.yyadsdk.util.ActivityUtils.getProcessName;


public class AdSDKManager {
    private static AdSDKManager instance;

    public static AdSDKManager getInstance() {
        if (instance == null) {
            synchronized (AdSDKManager.class) {
                if (instance == null) {
                    instance = new AdSDKManager();
                }
            }
        }
        return instance;
    }

    public void init(Context context) {
        String processName = getProcessName(context, android.os.Process.myPid());
        if (processName != null && processName.equalsIgnoreCase(context.getPackageName())) {
            GreenDaoManager.getInstance().init(context);
            ApiManage.getInstance().init(context);
            SpUtil.init(context);
            YoYoAdManager.init(context);
            context.startService(new Intent(context, KernelService.class));
        }
    }
}
